//
//  MineResaveViewController.m
//  NewProject
//
//  Created by dlios on 15/3/10.
//  Copyright (c) 2015年 dlios. All rights reserved.
//

#import "MineResaveViewController.h"

@interface MineResaveViewController ()

@end

@implementation MineResaveViewController

-(void)viewWillAppear:(BOOL)animated
{
    self.segment.selectedSegmentIndex = 0;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.segment = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"四季菜谱收藏", @"分类菜谱收藏", nil]];
    
    self.segment.frame = CGRectMake(self.view.frame.size.width / 5, 15, self.view.frame.size.width * 3 / 5, 30);
    self.navigationItem.titleView = self.segment;
    [self.segment addTarget:self action:@selector(controlPressed:) forControlEvents:UIControlEventValueChanged];
    self.navigationController.navigationBar.tintColor = [UIColor blueColor];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:@selector(back)];
    // Do any additional setup after loading the view.
}

-(void)back
{
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)controlPressed:(id)sender
{
    NSInteger segIndex = [self.segment selectedSegmentIndex];
    if (segIndex == 1) {
        
        MyClassResaveViewController *myClaVC = [[MyClassResaveViewController alloc] init];
        CATransition *animation = [CATransition animation];
        [animation setDuration:1.0];
        animation.type = @"oglFlip";
        [animation setSubtype:kCATransitionFromRight];
        [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]];
        
        [self.navigationController.view.layer addAnimation:animation forKey:nil];
        [self.navigationController pushViewController:myClaVC animated:NO];
        
    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
